import re

from uutil import util_download

if __name__ == "__main__":
    rows = util_download.read_excel_xlsx("D:\\202312061910-4.xlsx", 0)
    i = 0
    for row in rows:
        i = i + 1
        if i < 304:
            continue
        else:
            url = str(row[11].value)
            contract_id = str(row[1].value)
            agreement_name = str(row[3].value)
            if url is None:
                print(contract_id + agreement_name + "为空")
            else:
                url_ = url[0:4]
                if url_ != "http":
                    print(contract_id + agreement_name + "为空")
                else:
                    print(contract_id + agreement_name + "处理——" + str(i))
                    pattern = "-[_A-Z0-9a-z]*-"
                    match = re.search(pattern, contract_id)
                    if match:
                        search = match.span()
                        order_id = contract_id[int(search[0]) + 1 : int(search[1]) - 1]
                        dir = "合同1//" + str(order_id)
                        type = url[-3:]
                        util_download.download_by_url(url, dir, agreement_name, type)
